/*
 * @Author: caiwq caiwq@putron.com
 * @Date: 2022-07-29 10:44:22
 * @LastEditors: caiwq caiwq@putron.com
 * @LastEditTime: 2022-08-18 15:39:43
 * @FilePath: \LMX\src\utils\request.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import axios from 'axios'

const service = axios.create({
    baseURL: '/',
    withCredentials: false,
    timeout: 14000,
    // headers: {
    //     "Cookie": "login_type=admin"
    // }
})
service.interceptors.request.use(
    config => config,
    error => Promise.reject(error)
)

// 响应拦截器
service.interceptors.response.use(
    response => {
        const res = response.data
        // console.log(res,typeof res);
        // console.log(JSON.parse(response.data))
        return res.result === 1 || res.result === 0 ? res : Promise.reject(res || 'error')
        // return res
    },
    error => 
    {
        // console.log(error);
        Promise.reject(error)
    }
    // error=>error
)
export default service
